import rxAjax from '@/assets/js/ajax.js';

export const OsRelTypeApi = {};

OsRelTypeApi.baseUrl= '/api-user/user/org/osRelType';
OsRelTypeApi.exportUrl= OsRelTypeApi.baseUrl + '/listExport';

OsRelTypeApi.query=function (parameter) {
  var url= OsRelTypeApi.baseUrl + '/query';
  return rxAjax.postJson(url,parameter).then (res => {
    return res.result
  })
}

/**
 * 获取单记录
 * @param pkId
 * @returns {*}
 */
OsRelTypeApi.get =function(pkId) {
  var url= OsRelTypeApi.baseUrl + '/get?pkId=' + pkId;
  return rxAjax.get(url);
}

OsRelTypeApi.save =function(parameter) {
  var url= OsRelTypeApi.baseUrl + '/save';
  return rxAjax.postJson(url,parameter);
}

OsRelTypeApi.del =function(parameter) {
  var url= OsRelTypeApi.baseUrl + '/del';
  return rxAjax.postUrl(url,parameter);
}

OsRelTypeApi.getOsRelTypeOfGroupUser =function(dimId,level,tenantId){
  var url=OsRelTypeApi.baseUrl + '/getOsRelTypeOfGroupUser?dimId='+dimId;
  if(level){
    url += '&level='+level;
  }
  if(tenantId){
    url += '&tenantId='+tenantId;
  }
  return rxAjax.get(url);
}

OsRelTypeApi.getOsRelTypeOfGroupGroup =function(dimId,level,tenantId){
  var url=OsRelTypeApi.baseUrl + '/getOsRelTypeOfGroupGroup?dimId='+dimId;
  if(level){
    url += '&level='+level;
  }
  if(tenantId){
    url += '&tenantId='+tenantId;
  }
  return rxAjax.get(url);
}

export  default OsRelTypeApi;
